package com.r_z.mapper;


import com.r_z.entity.Goods;
import com.r_z.entity.PurchasePlan;
import com.r_z.entity.Repertory;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.List;
import java.util.Map;

/**
 * 功能
 * 类的描述:采购计划的sql接口类
 * @author 干净、
 * date 2022/05/30/9:59
 * @apiNote 1.0
 */
@Mapper
public interface GoodsMapper {

    /**
     * 从新增purchasePlan中间表
     * @param purchasePlan
     * @return
     */
    @Insert("INSERT INTO purchasePlan VALUES(#{goodId},#{goodName},#{goodUrl},#{price},#{quantity},1)")
    int insertPurchasePlan(PurchasePlan purchasePlan);

    /**
     * 查询goods 商品列表
     * @param page
     * @param limit
     * @param strWhere
     * @return
     */
    @Select("select * from goods where 1=1 ${strWhere} limit #{page},#{limit}")
    List<Goods> LimitselectGoods(@Param("page") int page,@Param("limit") int limit,@Param("strWhere") String strWhere);

    /**
     * 查询goods 商品列表总条数
     * @param strWhere
     * @return
     */
    @Select("select count(*) from goods where 1=1 ${strWhere}")
    int countselectGoods(@Param("strWhere") String strWhere);

    @Select("select * from purchasePlan")
    List<PurchasePlan> selectPurchase();

    @Select("select count(*) from purchasePlan where goodId=#{goodId}")
    int selectPurchase2(@Param("goodId") int goodId);

    /**
     * 查询purchasePlan中间表的数据
     * @param page
     * @param limit
     * @param strWhere
     * @return
     */
    @Select("select * from purchasePlan where 1=1 ${strWhere} limit #{page},#{limit}")
    List<PurchasePlan> selectPurchasePlan(@Param("page") int page,@Param("limit") int limit,@Param("strWhere") String strWhere);

    /**
     * 查询purchasePlan中间表的总条数
     * @param strWhere
     * @return
     */
    @Select("select count(*) from purchasePlan where 1=1 ${strWhere}")
    int CountPurchasePlan(@Param("strWhere") String strWhere);

    /**
     * 采购计划的删除方法
     * @param goodId 采购id
     */
    @Delete("delete from purchasePlan where goodId=#{goodId}")
    int deletePurchasePlan(int goodId);

    /**
     * 采购计划的修改方法
     * @param plan 采购计划实体
     */
    @Update("update purchasePlan set goodName=#{goodName},price=#{price},quantity=#{quantity} where goodId=#{goodId}")
    boolean updatePurchasePlan(PurchasePlan plan);

    /**
     * 删除所有采购计划数据的方法
     */
    @Delete("delete from purchasePlan")
    boolean dropPurchasePlanAll();

}
